﻿using Little.Soldier.SWIFT;
using Little.Soldier.SWIFT.Definition;
using System;
using System.Globalization;

namespace Little.Soldier.SWIFT.Messages.Category3
{
  public class Tag30F : SwiftTagWrapper
  {
    public string Value
    {
      get
      {
        return this.GetValue();
      }
      set
      {
        this.SetValue("30F", value);
      }
    }

    public DateTime Date
    {
      get
      {
        DateTime result = DateTime.MinValue;
        DateTime.TryParseExact(this.Value, "yyyyMMdd", (IFormatProvider) CultureInfo.CurrentCulture, DateTimeStyles.None, out result);
        return result;
      }
      set
      {
        this.Value = string.Format("{0:yyyyMMdd}", (object) value);
      }
    }

    internal Tag30F(SwiftElement parent, int index, SwiftDefinitionElement definition)
      : base(parent, index, definition)
    {
    }
  }
}
